| 1 | import { NextRequest, NextResponse } from 'next/server'; |
| 2 | import { setOutboxStatus } from '@/lib/db'; |
| 3 | |
| 4 | export const runtime = 'nodejs'; |
| 5 | export const dynamic = 'force-dynamic'; |
| 6 | |
| 7 | export async function POST(req: NextRequest, { params }: { params: Promise<{ id: string }> }) { |
| 8 | const { id } = await params; |
| 9 | const { action } = await req.json(); |
| 10 | if (!['approve', 'reject'].includes(action)) return NextResponse.json({ error: 'action must be approve|reject' }, { status: 400 }); |
| 11 | const status = action === 'approve' ? 'approved' : 'rejected'; |
| 12 | const o = setOutboxStatus(id, status); |
| 13 | if (!o) return NextResponse.json({ error: 'not found' }, { status: 404 }); |
| 14 | return NextResponse.json({ outbox: o }); |
| 15 | } |